package com.ruicar.afs.cloud.afscase.mq.approvesendinfo.service.impl;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruicar.afs.cloud.afscase.approvetask.entity.CaseApproveRecord;
import com.ruicar.afs.cloud.afscase.approvetask.entity.WorkProcessScheduleInfo;
import com.ruicar.afs.cloud.afscase.approvetask.service.WorkProcessScheduleInfoService;
import com.ruicar.afs.cloud.afscase.infomanagement.service.CaseCostInfoService;
import com.ruicar.afs.cloud.afscase.infomanagement.service.CaseDiscountDetailService;
import com.ruicar.afs.cloud.afscase.infomanagement.service.CaseFinancingItemsService;
import com.ruicar.afs.cloud.afscase.mq.approvesendinfo.PushDataForPos;
import com.ruicar.afs.cloud.afscase.mq.approvesendinfo.service.ApproveInformInfoService;
import com.ruicar.afs.cloud.afscase.mq.approvesendinfo.vo.CaseLogInfo;
import com.ruicar.afs.cloud.afscase.mq.approvesendinfo.vo.UrgentInfo;
import com.ruicar.afs.cloud.afscase.processor.enums.NormalSubmitType;
import com.ruicar.afs.cloud.afscase.processor.util.WorkflowTypeUtil;
import com.ruicar.afs.cloud.afscase.remind.entity.CaseRemindDetail;
import com.ruicar.afs.cloud.bizcommon.business.entity.FinCostDetails;
import com.ruicar.afs.cloud.bizcommon.business.entity.FinDiscountDetails;
import com.ruicar.afs.cloud.bizcommon.business.entity.FinFinancingItems;
import com.ruicar.afs.cloud.bizcommon.business.entity.FinRentAdjustDetails;
import com.ruicar.afs.cloud.bizcommon.business.service.ApplyRentAdjustDetailsService;
import com.ruicar.afs.cloud.common.core.enums.AfsEnumUtil;
import com.ruicar.afs.cloud.common.core.security.util.SecurityUtils;
import com.ruicar.afs.cloud.common.modules.afscorebusiness.enums.NoticeTypeEnum;
import com.ruicar.afs.cloud.common.modules.afscorebusiness.enums.ProcessTypeEnum;
import com.ruicar.afs.cloud.common.modules.afscorebusiness.enums.ResultBooleanEnum;
import com.ruicar.afs.cloud.common.modules.afscorebusiness.enums.SendApproveTypeEnum;
import com.ruicar.afs.cloud.common.modules.dto.mq.approve.*;
import com.ruicar.afs.cloud.common.mq.rabbit.message.AfsTransEntity;
import com.ruicar.afs.cloud.common.mq.rabbit.message.MqTransCode;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

//import com.ruicar.afs.cloud.afscore.mq.apply.dto.approve.*;

/**
 * @author jiaqi.guo
 * @version 1.0
 * @description: 组装数据
 * @created 2020/6/19 16:14
 */
@Slf4j
@Service
@AllArgsConstructor
@Order(Ordered.LOWEST_PRECEDENCE)
@ConditionalOnProperty(prefix = "com.ruicar.afs.cloud.mq.rabbit", name = "enable")
public class ApproveInformInfoServiceImpl implements ApproveInformInfoService {
    private final PushDataForPos infoSender;
    private final CaseCostInfoService caseCostInfoService;
    private final WorkProcessScheduleInfoService infoService;
    private final CaseFinancingItemsService financingItemsService;
    private final CaseDiscountDetailService discountDetailService;
    private final ApplyRentAdjustDetailsService rentAdjustDetailsService;


    @ApiOperation("审批通知")
    public void submitApprovalNotic(CaseApproveRecord record) {
        AfsTransEntity<ApproveSubmitInfo> transEntity = new AfsTransEntity();
        ApproveSubmitInfo approveSubmitInfo = new ApproveSubmitInfo();
        ApproveInformDto approveInformDto = this.getApproveInform(record);
        approveSubmitInfo.setApproveInformDto(approveInformDto);
        transEntity.setTransCode(MqTransCode.AFS_POS_APPLY_CASE_CTM_MODIFY_ORDER);
        transEntity.setData(approveSubmitInfo);
        infoSender.sendApprovalNotic(transEntity);

    }

    @ApiOperation("留言通知")
    public void submitLeaveMessage(CaseRemindDetail remindDetail) {
        AfsTransEntity<ApproveSubmitInfo> transEntity = new AfsTransEntity();
        ApproveSubmitInfo approveSubmitInfo = new ApproveSubmitInfo();
        LeaveMessageDto leaveMessageDto = this.getLeaveMessage(remindDetail);
        approveSubmitInfo.setLeaveMessageDto(leaveMessageDto);
        transEntity.setTransCode(MqTransCode.AFS_POS_APPLY_CASE_CTM_MODIFY_ORDER);
        transEntity.setData(approveSubmitInfo);
        infoSender.sendMessageNotic(transEntity);

    }

    @ApiOperation("经我处理追加留言通知")
    public void submitDealWithMessage(CaseRemindDetail remindDetail) {
        AfsTransEntity<ApproveSubmitInfo> transEntity = new AfsTransEntity();
        ApproveSubmitInfo approveSubmitInfo = new ApproveSubmitInfo();
        LeaveMessageDto leaveMessageDto = this.getLeaveMessage(remindDetail);
        approveSubmitInfo.setLeaveMessageDto(leaveMessageDto);
        transEntity.setTransCode(MqTransCode.AFS_POS_APPLY_CASE_CTM_DEAL_WITH_MESSAGE);
        transEntity.setData(approveSubmitInfo);
        infoSender.sendDealWithMessage(transEntity);
    }

    @ApiOperation("附条件核准")
    public void submitConditionalApproval(CaseApproveRecord record) {
        AfsTransEntity<ApproveSubmitInfo> transEntity = new AfsTransEntity();
        ApproveSubmitInfo approveSubmitInfo = new ApproveSubmitInfo();
        ConditionalApprovalDto conditionalApprovalDto = this.getCondionalApprove(record);
        approveSubmitInfo.setConditionalApprovalDto(conditionalApprovalDto);
        transEntity.setTransCode(MqTransCode.AFS_POS_APPLY_CASE_CTM_MODIFY_ORDER);
        transEntity.setData(approveSubmitInfo);
        infoSender.sendConditionalApproval(transEntity);
    }

    @ApiOperation("进件数据落库结果通知")
    @Override
    public void incomingApplyResult(CaseLogInfo logInfo) {
        AfsTransEntity<ApproveSubmitInfo> transEntity = new AfsTransEntity();
        ApproveSubmitInfo approveSubmitInfo = new ApproveSubmitInfo();
        ApplyResultInfoDto applyResultInfoDto = this.getApplayResult(logInfo);
        approveSubmitInfo.setApplyResultInfoDto(applyResultInfoDto);
        transEntity.setTransCode(MqTransCode.AFS_POS_APPLY_CASE_CTM_MODIFY_ORDER);
        transEntity.setData(approveSubmitInfo);
        infoSender.incomingApplyResult(transEntity);
    }

    @ApiOperation("加急通知")
    @Override
    public void turnUrgentResult(UrgentInfo urgentInfo) {
        AfsTransEntity<ApproveSubmitInfo> transEntity = new AfsTransEntity<>();
        ApproveSubmitInfo approveSubmitInfo = new ApproveSubmitInfo();
        CaseUrgentDto caseUrgentDto = this.getCaseUrgentMessage(urgentInfo);
        approveSubmitInfo.setCaseUrgentDto(caseUrgentDto);
        transEntity.setTransCode(MqTransCode.AFS_POS_APPLY_CASE_CTM_TURN_URGENT);
        transEntity.setData(approveSubmitInfo);
        infoSender.sendTurnUrgentResult(transEntity);
    }

    /**
     * 审批通知
     */
    private ApproveInformDto getApproveInform(CaseApproveRecord record) {
        ApproveInformDto informDto = new ApproveInformDto();
        //申请标号
        informDto.setApplyNo(record.getApplyNo());
        // modify by pengJinbo 审批类型转换 20200629
        Map<String, SendApproveTypeEnum> translateMap = new HashMap<>();
        translateMap.put(SendApproveTypeEnum.PENDING_REVIEW.getCode(), SendApproveTypeEnum.PENDING_REVIEW);
        translateMap.put(AfsEnumUtil.key(NormalSubmitType.SUGGEST_CHECK_FINAL), SendApproveTypeEnum.APPROVAL);
        translateMap.put(AfsEnumUtil.key(NormalSubmitType.SUGGEST_REJECT_FINAL), SendApproveTypeEnum.REJECTION);
        translateMap.put(AfsEnumUtil.key(NormalSubmitType.SUGGEST_CANCEL), SendApproveTypeEnum.CANCELLATION);
        translateMap.put(AfsEnumUtil.key(NormalSubmitType.SEND_BACK_TO_DEALER), SendApproveTypeEnum.BACK);
        translateMap.put(SendApproveTypeEnum.AUDIT.getCode(), SendApproveTypeEnum.AUDIT);
        //审批类型
        informDto.setApproveType(translateMap.containsKey(record.getApproveSuggest()) ? translateMap.get(record.getApproveSuggest()).getCode() : "");
        //原因
        informDto.setApproveReason(record.getApproveReason());
        //流程实例ID
        informDto.setStageId(record.getStageId());
        //时间
        informDto.setOccurrenceTime(new Date());
        //审批意见
        informDto.setApproveSuggest(record.getApproveSuggest());
        //留言
        informDto.setLeaveMessage(record.getApproveMessage());

        WorkProcessScheduleInfo scheduleInfo = infoService.getById(record.getId());
        if (ObjectUtils.isNotEmpty(scheduleInfo)) {
            informDto.setProcessType(WorkflowTypeUtil.getApproveTypeCode(scheduleInfo.getAfsFlowKey()));
        }
        return informDto;
    }

    /**
     * 复议通知
     *
     * @param record
     * @return
     */
    private ApplyResultInfoDto getReconsiderationInfo(CaseApproveRecord record) {
        ApplyResultInfoDto applyResultInfoDto = new ApplyResultInfoDto();
        //申请编号
        applyResultInfoDto.setApplyNo(record.getApplyNo());
        applyResultInfoDto.setNoticeType(NoticeTypeEnum.APPROVALRESULT.getCode());
        applyResultInfoDto.setResult(ResultBooleanEnum.TRUE.getCode());
        return applyResultInfoDto;
    }

    /**
     * 留言通知
     */
    private LeaveMessageDto getLeaveMessage(CaseRemindDetail caseRemindDetail) {
        LeaveMessageDto leaveMessageDto = new LeaveMessageDto();
        leaveMessageDto.setApplyNo(caseRemindDetail.getApplyNo());
        // 操作类型;退回经销商/暂停案件
        leaveMessageDto.setIsRturn(caseRemindDetail.getOperationType());
        //留言内容
        leaveMessageDto.setMessageInfo(caseRemindDetail.getRemindContent());
        //留言原因
        leaveMessageDto.setMessageReason(caseRemindDetail.getRemindReason());
        //留言类型
        leaveMessageDto.setMessageType(caseRemindDetail.getRemindType());
        //时间
        leaveMessageDto.setMessageTime(new Date());
        //通知类型，区分复议
        leaveMessageDto.setFlowType(caseRemindDetail.getNoticeType());
        return leaveMessageDto;
    }

    /**
     * 附条件核准
     */
    private ConditionalApprovalDto getCondionalApprove(CaseApproveRecord record) {

        ConditionalApprovalDto conditionalApprovalDto = new ConditionalApprovalDto();
        //申请编号
        conditionalApprovalDto.setApplyNo(record.getApplyNo());
        String condition = this.getConditionalApprovalInfo(record.getApplyNo());
        //JSON
        conditionalApprovalDto.setConditionalApproval(condition);
        //内容
        conditionalApprovalDto.setConditionalInfo(record.getApproveRemark());
        //原因
        conditionalApprovalDto.setConditionalReason(record.getApproveReason());
        //时间
        conditionalApprovalDto.setConditionalTime(new Date());
        //流程类型
        WorkProcessScheduleInfo scheduleInfo = infoService.getById(record.getId());
        if (ObjectUtils.isNotEmpty(scheduleInfo)) {
            conditionalApprovalDto.setProcessType(WorkflowTypeUtil.getApproveTypeCode(scheduleInfo.getAfsFlowKey()));
        }
        return conditionalApprovalDto;

    }

    /**
     * 进件数据落库结果通知
     */
    private ApplyResultInfoDto getApplayResult(CaseLogInfo logInfo) {
        ApplyResultInfoDto applyResultInfoDto = new ApplyResultInfoDto();
        // 申请编号
        applyResultInfoDto.setApplyNo(logInfo.getApplyNo());
        // 返回结果
        applyResultInfoDto.setResult(logInfo.getResult());
        return applyResultInfoDto;
    }

    /**
     * 加急通知结果
     *
     * @param urgentInfo
     * @return
     */
    private CaseUrgentDto getCaseUrgentMessage(UrgentInfo urgentInfo) {
        CaseUrgentDto caseUrgentDto = new CaseUrgentDto();
        //申请编号
        caseUrgentDto.setApplyNo(urgentInfo.getApplyNo());
        //加急结果
        caseUrgentDto.setIsSuccess(urgentInfo.getResult());
        return caseUrgentDto;
    }

    @ApiOperation("资产变更审批结果通知")
    public void approveChangeAssets(CaseApproveRecord approveRecord) {
        AfsTransEntity<ApproveSpecialSubmitInfo> transEntity = new AfsTransEntity<>();
        ApproveSpecialSubmitInfo specialSubmitInfo = new ApproveSpecialSubmitInfo();
        ApproveInformDto approveInformDto = this.getChangeAssetsForApprove(approveRecord);
        specialSubmitInfo.setApproveInformDto(approveInformDto);
        transEntity.setTransCode(MqTransCode.AFS_POS_APPLY_CASE_CTM_ASSETS_RECONSIDER);
        transEntity.setData(specialSubmitInfo);
        infoSender.sendChangeAssetsResult(transEntity);
    }

    @ApiOperation("复议申请审批结果通知")
    public void approveReconsideration(CaseApproveRecord approveRecord) {
        AfsTransEntity<ReconsiderationDto> transEntity = new AfsTransEntity<>();
        ReconsiderationDto reconsiderationDto = new ReconsiderationDto();
        ApplyResultInfoDto resultInfoDto = this.getReconsiderationForApprove(approveRecord);
        reconsiderationDto.setResultInfoDto(resultInfoDto);
        transEntity.setTransCode(MqTransCode.AFS_POS_APPLY_CASE_CTM_ASSETS_RECONSIDERATION);
        transEntity.setData(reconsiderationDto);
        infoSender.sendReconsideResult(transEntity);
    }


    /**
     * @description: 资产变更审批结果组装
     * @author jiaqi.guo
     * @created 2020/7/30 10:19
     * @version 1.0
     */
    private ApproveInformDto getChangeAssetsForApprove(CaseApproveRecord record) {
        ApproveInformDto approveInformDto = new ApproveInformDto();
        //申请编号
        approveInformDto.setApplyNo(record.getApplyNo());
        approveInformDto.setApproveReason(record.getApproveReason());
        approveInformDto.setApproveType(record.getApproveSuggest());
        approveInformDto.setOccurrenceTime(new Date());
        approveInformDto.setProcessType(AfsEnumUtil.key(ProcessTypeEnum.CHANGE_ASSETS));
        approveInformDto.setStageId(record.getStageId());
        approveInformDto.setApproveSuggest(record.getApproveRemark());
        log.info("审批数据提交!{}",record.getApproveType());
        return approveInformDto;
    }

    /**
     * @description: 复议申请审批结果组装
     * @author jiaqi.guo
     * @created 2020/7/30 10:19
     * @version 1.0
     */
    private ApplyResultInfoDto getReconsiderationForApprove(CaseApproveRecord record) {
        ApplyResultInfoDto resultInfoDto = new ApplyResultInfoDto();
        //申请编号
        resultInfoDto.setNoticeType(NoticeTypeEnum.APPROVALRESULT.getCode());
        resultInfoDto.setApplyNo(record.getApplyNo());
        if (ObjectUtils.isNotEmpty(record)) {
            //核准
            if (record.getApproveSuggest().equals(AfsEnumUtil.key(NormalSubmitType.SUGGEST_CHECK))
                    || record.getApproveSuggest().equals(AfsEnumUtil.key(NormalSubmitType.SUGGEST_CHECK_FINAL))
                   ) {
                //true
                resultInfoDto.setResult(ResultBooleanEnum.TRUE.getCode());
                resultInfoDto.setApproveType(record.getApproveType());
                resultInfoDto.setApproveDemand(record.getApproveReason());
                log.info("复议申请审批结果通知:{}", ResultBooleanEnum.TRUE.getCode());

            }
            //拒绝，撤销
            if (record.getApproveSuggest().equals(AfsEnumUtil.key(NormalSubmitType.SUGGEST_CANCEL))
                    || record.getApproveSuggest().equals(AfsEnumUtil.key(NormalSubmitType.SUGGEST_REJECT_FINAL))) {
                //false
                resultInfoDto.setResult(ResultBooleanEnum.FALSE.getCode());
                resultInfoDto.setApproveType(record.getApproveType());
                resultInfoDto.setApproveDemand(record.getApproveReason());
                log.info("复议申请审批结果通知:{}", ResultBooleanEnum.FALSE.getCode());

            }
            if(record.getApproveSuggest().equals(SendApproveTypeEnum.PENDING_REVIEW.getCode())){
                resultInfoDto.setNoticeType(null);
                resultInfoDto.setApproveType(record.getApproveType());
                resultInfoDto.setResult(ResultBooleanEnum.TRUE.getCode());
            }

        } else {
            log.info("无申请数据提交!");
        }

        return resultInfoDto;
    }

    @ApiOperation("资产变更数据落库结果通知")
    public void changeAssetsResult(CaseLogInfo logInfo) {
        AfsTransEntity<ApproveSpecialSubmitInfo> transEntity = new AfsTransEntity<>();
        ApproveSpecialSubmitInfo specialSubmitInfo = new ApproveSpecialSubmitInfo();
        ApplyResultInfoDto resultInfoDto = this.getChangeAssetsForLibrary(logInfo);
        specialSubmitInfo.setResultInfoDto(resultInfoDto);
        transEntity.setTransCode(MqTransCode.AFS_POS_APPLY_CASE_CTM_ASSETS_RECONSIDER);
        transEntity.setData(specialSubmitInfo);
        infoSender.changeAssetsResult(transEntity);
    }

    /**
     * @description: 资产变更落库结果通知
     * @author jiaqi.guo
     * @created 2020/7/30 10:19
     * @version 1.0
     */
    private ApplyResultInfoDto getChangeAssetsForLibrary(CaseLogInfo logInfo) {
        ApplyResultInfoDto resultInfoDto = new ApplyResultInfoDto();
        //申请编号
        resultInfoDto.setNoticeType(NoticeTypeEnum.FALLLIBRARY.getCode());
        resultInfoDto.setApplyNo(logInfo.getApplyNo());
        resultInfoDto.setResult(logInfo.getResult());
        log.info("资产变更落库结果通知成功！！！");
        return resultInfoDto;
    }

    @ApiOperation("资产变更审批通知")
    public void submitApprovalNoticForAssets(CaseApproveRecord record) {
        AfsTransEntity<ApproveSpecialSubmitInfo> transEntity = new AfsTransEntity();
        ApproveSpecialSubmitInfo specialSubmitInfo = new ApproveSpecialSubmitInfo();
        ApproveInformDto approveInformDto = this.getApproveInform(record);
        log.info("资产变更审批意见:{}",approveInformDto.getApproveType());
        specialSubmitInfo.setApproveInformDto(approveInformDto);
        transEntity.setTransCode(MqTransCode.AFS_POS_APPLY_CASE_CTM_ASSETS_RECONSIDER);
        transEntity.setData(specialSubmitInfo);
        infoSender.sendApprovalNoticForAssets(transEntity);

    }

    @ApiOperation("复议申请审批通知")
    public void submitReconsideration(CaseApproveRecord record) {
        AfsTransEntity<ReconsiderationDto> transEntity = new AfsTransEntity<>();
        ReconsiderationDto reconsiderationDto = new ReconsiderationDto();
        ApplyResultInfoDto applyResultInfoDto = this.getReconsiderationInfo(record);
        reconsiderationDto.setResultInfoDto(applyResultInfoDto);
        transEntity.setTransCode(MqTransCode.AFS_POS_APPLY_CASE_CTM_ASSETS_RECONSIDERATION);
        transEntity.setData(reconsiderationDto);
        infoSender.sendApprovalNoticForReconsideration(transEntity);
    }

    @ApiOperation("资产变更留言通知")
    public void submitLeaveMessageForAssets(CaseRemindDetail remindDetail) {
        AfsTransEntity<ApproveSpecialSubmitInfo> transEntity = new AfsTransEntity();
        ApproveSpecialSubmitInfo specialSubmitInfo = new ApproveSpecialSubmitInfo();
        LeaveMessageDto leaveMessageDto = this.getLeaveMessage(remindDetail);
        specialSubmitInfo.setLeaveMessageDto(leaveMessageDto);
        transEntity.setTransCode(MqTransCode.AFS_POS_APPLY_CASE_CTM_ASSETS_RECONSIDER);
        transEntity.setData(specialSubmitInfo);
        infoSender.sendMessageNoticForAssets(transEntity);

    }

    @ApiOperation("组装附条件数据")
    private String getConditionalApprovalInfo(String applyNo) {
        JSONObject object = new JSONObject();
        List<FinCostDetails> finCostInfoArrayList = caseCostInfoService.list(Wrappers.<FinCostDetails>query().lambda()
                .eq(FinCostDetails::getApplyNo, applyNo));
        JSONArray arrayCost = new JSONArray();
        arrayCost.addAll(finCostInfoArrayList);
        object.put("finCostDetailsList", arrayCost);
        log.info("附条件新融资信息组装成功！！！");

        List<FinDiscountDetails> caseDiscountDetailArrayList = discountDetailService.list(Wrappers.<FinDiscountDetails>query().lambda()
                .eq(FinDiscountDetails::getApplyNo, applyNo));
        JSONArray arrayDiscount = new JSONArray();
        arrayDiscount.addAll(caseDiscountDetailArrayList);
        object.put("finDiscountDetailsList", arrayDiscount);
        log.info("附条件新贴息组装成功！！！");

        List<FinFinancingItems> finFinancingItemsArrayList = financingItemsService.list(Wrappers.<FinFinancingItems>query().lambda()
                .eq(FinFinancingItems::getApplyNo, applyNo));
        JSONArray arrayFinancing = new JSONArray();
        arrayFinancing.addAll(finFinancingItemsArrayList);
        object.put("finFinancingItemsList", arrayFinancing);
        log.info("附条件新融资项组装成功！！！");

        List<FinRentAdjustDetails> finRentAdjustDetailsArrayList = rentAdjustDetailsService.list(Wrappers.<FinRentAdjustDetails>query().lambda()
                .eq(FinRentAdjustDetails::getApplyNo, applyNo));
        JSONArray arrayRentAdjust = new JSONArray();
        arrayRentAdjust.addAll(finRentAdjustDetailsArrayList);
        object.put("finRentAdjustDetailsList", arrayRentAdjust);
        log.info("附条件新租金组装成功！！！");

        return object != null ? object.toString() : "";
    }

    @ApiOperation("经销商提交撤回申请")
    @Override
    public void submitCallBackResult(String applyNO,String callBackResult,String lastBusinessStateIn) {
        AfsTransEntity<CallBackApplyResultDto> transEntity = new AfsTransEntity<>();
        CallBackApplyResultDto callBackApplyResultDto = new CallBackApplyResultDto();
        callBackApplyResultDto.setApplyNo(applyNO);
        callBackApplyResultDto.setResult(callBackResult);
        callBackApplyResultDto.setBusinessStateIn(lastBusinessStateIn);
        transEntity.setTransCode(MqTransCode.AFS_POS_APPLY_CASE_CTM_CALL_BACK);
        transEntity.setData(callBackApplyResultDto);
        infoSender.sendCallBackNotice(transEntity);
    }

    @ApiOperation("审批员向经销商端提交撤回申请")
    @Override
    public void submitApproveCallBackApply(String applyNO, String businessStateIn,String scheduleId) {
        AfsTransEntity<CallBackApplyDto> transEntity = new AfsTransEntity<>();
        CallBackApplyDto callBackApplyDto = new CallBackApplyDto();
        callBackApplyDto.setApplyNo(applyNO);
        callBackApplyDto.setBusinessStateIn(businessStateIn);
        callBackApplyDto.setScheduleId(scheduleId);
        callBackApplyDto.setCallbackUsername(SecurityUtils.getUsername());
        callBackApplyDto.setCallBackUserRealName(SecurityUtils.getUser().getUserRealName());
        transEntity.setTransCode(MqTransCode.AFS_POS_APPLY_CASE_CTM_APPROVE_CALL_BACK);
        transEntity.setData(callBackApplyDto);
        infoSender.sendApproveCallBackApply(transEntity);
    }


    /**
     * @description: 审批过程‘打开’状态通知
     * @author jiaqi.guo
     * @created 2020/9/9 15:25
     * @version 1.0
     */
    @ApiOperation("审批过程‘打开’状态通知")
    public void incomingApproveOpenResult(ApproveOpenDto approveOpenDto) {
        AfsTransEntity<ApproveOpenResult> transEntity = new AfsTransEntity();
        ApproveOpenResult approveOpenResult = new ApproveOpenResult();
        log.info("审批过程‘打开’状态对应流程:{}", approveOpenDto.getProcessType());
        if(ObjectUtils.isNotEmpty(approveOpenDto)){
            approveOpenResult.setApplyNo(approveOpenDto.getApplyNo());
            approveOpenResult.setApproveOpenDto(approveOpenDto);
            transEntity.setTransCode(MqTransCode.AFS_POS_APPLY_CASE_CTM_APPROVE_OPEN_RESULT);
            transEntity.setData(approveOpenResult);
            infoSender.incomingApproveOpenResult(transEntity);
        }

    }
    /**
     * @description:附条件核准、核准、退回经销商数据推送
     * @author jiaqi.guo
     * @created 2020/9/18 22:20
     * @version 1.0
     */
    @ApiOperation("附条件核准、核准、退回经销商数据推送")
    public void caseUpdateInfoSend(CaseUpdateInfoSend caseUpdateInfoSend){
        AfsTransEntity<CaseUpdateInfoSend> transEntity = new AfsTransEntity();
        log.info("附条件核准、核准、退回经销商数据推送:{}", caseUpdateInfoSend.getApplyNo()+caseUpdateInfoSend.getApproveSuggest());
        if(ObjectUtils.isNotEmpty(caseUpdateInfoSend)){
            transEntity.setTransCode(MqTransCode.AFS_POS_APPLY_CASE_CTM_APPROVE_CASE_UPDATE_SEND);
            transEntity.setData(caseUpdateInfoSend);
            infoSender.caseUpdateInfoSend(transEntity);
        }
    }


}